package com.googlecode.jlsf.swing;

import com.googlecode.jlsf.IP;

/**
 * An IP range implementation for ranges's list
 */
public class Range
{
	private String title;
	private IP fromIp, toIp;
	private int netmask;
	
	public Range(String title, IP fromIp, IP toIp, int netmask) throws IllegalArgumentException
	{
		this.title = title;
		
		if((fromIp.getNetmask() != toIp.getNetmask()) || (fromIp.getNetmask() != netmask))
			throw new IllegalArgumentException("Wrong netmask");
		
		this.fromIp = fromIp;
		this.toIp = toIp; 
		this.netmask = netmask;
	}
	
	public String toString()
	{
		return title;
	}
	
	public IP[] getIPs()
	{
		return new IP[] {fromIp, toIp};
	}
	
	public int getNetmask()
	{
		return netmask;
	}
	
	/*public void setIPs(IP fromIp, IP toIp) throws IllegalArgumentException
	{
		if((fromIp.getNetmask() != toIp.getNetmask()) || (fromIp.getNetmask() != netmask))
			throw new IllegalArgumentException("Wrong netmask");
		
		this.fromIp = fromIp;
		this.toIp = toIp;
	}
	
	public void setNetmask(int netmask) throws IllegalArgumentException
	{
		if(fromIp.getNetmask() != netmask)
			throw new IllegalArgumentException("Wrong netmask");
		
		this.netmask = netmask;
	}*/
	
}
